//
//  OneCell.m
//  BeautyClother
//
//  Created by dllo on 15/9/19.
//  Copyright (c) 2015年 宋爽. All rights reserved.
//

#import "OneCell.h"

@implementation OneCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.avatar = [[UIImageView alloc] init];
        [self.contentView addSubview:_avatar];
        [_avatar release];
        
        self.username = [[UILabel alloc] init];
        [self.contentView addSubview:_username];
        [_username release];
        
        self.date = [UIButton buttonWithType:UIButtonTypeSystem];
        [self.contentView addSubview:_date];
        
        self.desc = [[UILabel alloc] init];
        [self.contentView addSubview:_desc];
        [_desc release];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    CGFloat offWidth = [UIScreen mainScreen].bounds.size.width /375;
    CGFloat offHeight = [UIScreen mainScreen].bounds.size.height / 667;
    
    
    self.avatar.frame = CGRectMake(10 * offWidth, 10 * offHeight, 50 *offHeight, 50 * offHeight);
    self.avatar.layer.cornerRadius = 25;
    self.avatar.layer.masksToBounds = YES;
    
    self.username.frame = CGRectMake(75 * offWidth, 10 * offHeight, 100 * offWidth, 25 * offHeight);
    self.username.textColor = [UIColor colorWithRed:255/255 green:0 blue:255/255 alpha:0.8];
    
    
    self.date.frame = CGRectMake(70 * offWidth, 35 * offHeight, 100 * offWidth, 25 * offHeight);
    
    [self.date setImage:[UIImage imageNamed:@"date.png"] forState:UIControlStateNormal];
    [self.date setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
//    [date setTitle:[self.dic objectForKey:@"dateTime"] forState:UIControlStateNormal];
    self.date.titleLabel.font = [UIFont systemFontOfSize:12];
    
    
    
    self.desc.frame = CGRectMake(20 * offWidth, 100 * offHeight, self.contentView.frame.size.width - 60 * offWidth, 80* offHeight);
    self.desc.textColor = [UIColor darkGrayColor];
    self.desc.font = [UIFont systemFontOfSize:15];
    self.desc.numberOfLines = 0;
}

- (void)sendArr:(NSMutableArray *)array
{
    CGFloat offWidth = [UIScreen mainScreen].bounds.size.width /375;
    CGFloat offHeight = [UIScreen mainScreen].bounds.size.height / 667;
    for (int i = 0; i < array.count; i++) {
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(20 + 70 * offWidth * (i % 6), 80 * offHeight + 10 * (i / 6), 50 *offWidth, 25 * offHeight)];
        [self.contentView addSubview:label];
        label.text = [[[array objectAtIndex:i]objectForKey:@"component"]objectForKey:@"tag"];
        label.textColor = [UIColor colorWithRed:255/255 green:0 blue:255/255 alpha:0.5];
        [label release];
    }
}

@end
